Skip to main content

Format Conversion Scripts

Utilities for converting planetary geospatial data between various formats including ISIS3, 3D mesh formats, and specialized projections.

Astropedia_gdal2ISIS3.py

Creates ISIS3-compatible cube files with detached labels from GDAL-supported images.

Usage

python Astropedia_gdal2ISIS3.py [options] input.tif output.cub

Parameters

input.tif
string
required
Input GDAL-supported georeferenced image
output.cub
string
required
Output ISIS3 cube filename

Options

-debug
flag
Print detailed image information during processing
-noimage
flag
Generate only the label file (.lbl) without creating the image cube
-attach
flag
Attach the label to the ISIS image using ISIS3 cubeatt (requires ISIS3 installation)
-force360
flag
Force longitude domain to 0-360 instead of -180 to 180
-centerLon
float
Override the center longitude value
-centerLon 180
-base
float
Set the pixel base value for DN conversion
-base 17374000
-multiplier
float
Set the pixel multiplier/scale value
-multiplier 0.5

Output Files

The script creates multiple output files:
  • output.cub - Raw image data in ENVI format
  • output.lbl - ISIS3 detached label with metadata
  • output.History.IsisCube - Processing history

Supported Projections

  • Simple Cylindrical (GEOGCS)
  • Equirectangular
  • Sinusoidal
  • Transverse Mercator
  • Orthographic
  • Mercator
  • Polar Stereographic (North/South)

Example

# Basic conversion
python Astropedia_gdal2ISIS3.py mars_mola.tif mars_mola.cub

# With 360 longitude domain
python Astropedia_gdal2ISIS3.py -force360 moon_dem.tif moon_dem.cub

# Set custom base and multiplier
python Astropedia_gdal2ISIS3.py -base 17374000 -multiplier 0.5 input.tif output.cub

Data Types Supported

  • Byte - 8-bit unsigned integer
  • Int16 - 16-bit signed integer
  • UInt16 - 16-bit unsigned integer
  • Float32 - 32-bit floating point
  • Float64 - Converted to Float32
Float32/Real types do not use base and multiplier in ISIS3. Use the ISIS fx command to apply offsets to floating-point data.

gdal2PLY.py

Converts digital elevation models (DEMs) to PLY mesh format for 3D visualization.

Usage

python gdal2PLY.py input_DEM.tif output_mesh.ply

Parameters

input_DEM.tif
string
required
Input DEM in any GDAL-supported format
output_mesh.ply
string
required
Output PLY mesh file (binary format)

Features

  • Creates binary PLY format for efficient storage
  • Generates triangulated mesh from DEM grid
  • Preserves X, Y, Z coordinates
  • Suitable for import into 3D visualization software

NoData Handling

The script does not currently handle NoData values. Use this workaround:
  1. Find the minimum elevation:
    gdalinfo -mm input_DEM.tif
    
  2. Set NoData to a value below minimum and resample:
    gdalwarp -dstnodata -2791 -tr 10 10 -r bilinear input_DEM.tif output_DEM_10m.tif
    
  3. Run gdal2PLY on the processed file

Example

# Prepare DEM with NoData handling
gdalwarp -dstnodata -2791 -tr 10 10 -r bilinear raw_dem.tif dem_10m_nodata.tif

# Convert to PLY
python gdal2PLY.py dem_10m_nodata.tif terrain_mesh.ply

Output Format

PLY format includes:
  • Vertex positions (x, y, z)
  • Triangle face definitions
  • Binary encoding for efficiency

gdal2gores.py

Remaps Simple Cylindrical projected images into gore projections for printing and mounting on spheres.

Usage

python gdal2gores.py -ng number_of_gores infile outfile

Parameters

-ng
integer
required
Number of gores to generate (default: 8)
-ng 12  # Create 12 gores
infile
string
required
Input Simple Cylindrical map projection image
outfile
string
required
Output gore image (GeoTIFF format)
-q
flag
Quiet mode - suppress progress output

How It Works

  1. Divides the input image into N vertical strips (gores)
  2. Applies cosine warping to each gore based on latitude
  3. Creates output suitable for cutting and mounting on spherical objects

Example

# Create 8 gores (default)
python gdal2gores.py -ng 8 mars_map.tif mars_gores.tif

# Create 12 gores for finer detail
python gdal2gores.py -ng 12 moon_map.tif moon_gores.tif

Use Cases

  • Creating physical globe models
  • Educational materials
  • Art and craft projects with planetary maps
  • Tennis ball or baseball sphere mapping
Input image must be in Simple Cylindrical projection. Use gdalwarp to reproject if necessary.

gdal2xyz_geocentricSpace.py

Converts elevation DEMs to geocentric (body-fixed) XYZ ASCII coordinates.

Usage

python gdal2xyz_geocentricSpace.py [options] srcfile [dstfile]

Parameters

srcfile
string
required
Input elevation DEM (elevation values in meters)
dstfile
string
Output ASCII file (defaults to stdout)

Options

-skip
integer
Sampling factor to skip pixels (default: 1)
-skip 10  # Sample every 10th pixel
-radius
float
Body radius in meters (default: 1737400.0 for Moon)
-radius 3396190  # Mars radius
-radiusBand
integer
Band number containing variable radius values
-radiusBand 2
-latBand
integer
Band number containing latitude values
-latBand 2
-lonBand
integer
Band number containing longitude values
-lonBand 3
-band
integer
Elevation band number (default: 1)
-band 1
-srcwin
xoff yoff width height
Process only a subset window
-srcwin 0 0 1000 1000
-addheader
flag
Add CSV header line to output
-printLatLon
flag
Output Lon,Lat,Elevation instead of X,Y,Z

Output Format

Default output (body-fixed coordinates):
X,Y,Z
1234567.890,2345678.901,3456789.012
...
With -printLatLon:
Lon,Lat,Elevation
-122.456,37.789,1234.56
...

Coordinate Calculation

For spherical bodies:
X = (radius + elevation) * cos(lat) * cos(lon)
Y = (radius + elevation) * cos(lat) * sin(lon)
Z = (radius + elevation) * sin(lat)

Example

# Moon DEM to XYZ with default radius
python gdal2xyz_geocentricSpace.py -addheader moon_dem.tif moon_xyz.csv

# Mars DEM with custom radius, every 10th pixel
python gdal2xyz_geocentricSpace.py -radius 3396190 -skip 10 mars_dem.tif mars_xyz.csv

# Use lat/lon from bands instead of projection
python gdal2xyz_geocentricSpace.py -latBand 2 -lonBand 3 multiband.tif output.csv

Default Radii

  • Moon: 1,737,400 m
  • Mars: 3,396,190 m (use -radius option)
  • Other bodies: specify with -radius

AsterMeta2Shapefile.py

Converts a directory of ASTER metadata (.meta) files into a polygon shapefile.

Usage

python AsterMeta2Shapefile.py outfile.shp

Parameters

outfile.shp
string
required
Output shapefile name

How It Works

  1. Searches current directory for all *.meta files
  2. Extracts corner coordinates from each metadata file
  3. Creates polygon features with ASTER scene ID as attribute
  4. Outputs WGS84 geographic coordinate system shapefile

Metadata File Format

Expects ASTER metadata files with format:
ID=AST_L1B_00301012000010829
ULLat=37.123456
ULLong=-122.123456
URLat=37.234567
URLong=-122.012345
LRLat=37.012345
LRLong=-122.234567
LLLat=37.123456
LLLong=-122.345678

Example

# Run in directory containing *.meta files
python AsterMeta2Shapefile.py aster_coverage.shp
Output:
complete. 150 files processed

Output Attributes

  • Name - ASTER scene identifier
  • Geometry - Polygon footprint

Use Cases

  • Creating ASTER scene coverage maps
  • Planning data acquisitions
  • Visualizing available data in GIS
  • Filtering scenes by location
Script will exit if output shapefile already exists. Remove existing file first.

ogr_footprintinit2shp (footprintinit2shp.py)

Converts ISIS3 caminfo geometry PVL files to ESRI Shapefiles with WKT geometry.

Usage

python footprintinit2shp.py input.pvl [projection.prj]

Parameters

input.pvl
string
required
Input PVL file from ISIS3 caminfo command
projection.prj
string
WKT projection file to define coordinate system

ISIS3 Workflow

To create a PVL file ready for this tool:
1

Initialize SPICE data

spiceinit from=input.cub
2

Generate footprint

footprintinit from=input.cub
3

Extract camera info

caminfo from=input.cub to=output.pvl uselabel=yes
4

Convert to shapefile

python footprintinit2shp.py output.pvl projection.prj

Output Files

Creates multiple files:
  • .shp - Shapefile geometry
  • .shx - Shapefile index
  • .dbf - Attribute database
  • .prj - Projection file (if input projection provided)
  • .csv - Intermediate CSV with WKT
  • .vrt - Virtual format file

Use Cases

  • Footprint cataloging - Create spatial index of image coverage
  • Mission planning - Visualize existing image coverage
  • Data discovery - Find images covering specific regions
Column names from PVL will be truncated to fit shapefile field name limits (10 characters).

ogr_isisminer2shp (isisminer2shp.py)

Converts ISIS3 isisminer CSV results to ESRI Shapefiles.

Usage

python isisminer2shp.py input.csv [projection.prj]

Parameters

input.csv
string
required
Input CSV file from isisminer command
projection.prj
string
WKT projection file for coordinate system definition

Requirements

Input CSV must contain geometry columns. Common isisminer geometry formats:
  • WKT (Well-Known Text) geometry column
  • Separate latitude/longitude columns
  • Footprint polygon coordinates

Use Cases

  • Analysis results visualization - Convert isisminer analysis to GIS format
  • Quality control - Spatially review data mining results
  • Integration - Combine with other GIS datasets

Requirements

Common Dependencies

All conversion scripts require:
  • Python 2.7+ or Python 3.x (script-dependent)
  • GDAL/OGR Python bindings

Additional Dependencies

  • gdal2PLY.py: NumPy
  • gdal2xyz_geocentricSpace.py: NumPy/Numeric
  • ogr_footprintinit2shp: pvl library
  • ogr_isisminer2shp: pvl library (if using WKT geometry)

Installation

# Install GDAL and NumPy
conda install -c conda-forge gdal numpy

# For PDS4 conversion (pvl library)
pip install pvl

Author

Developed by Trent Hare and contributors at USGS Astrogeology Science Center.